<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" href="./css/add.css" type="text/css">
		<script type="text/javascript">
			function vaild(){
			    var pname = document.getElementById("pname").value;
				 var request = new XMLHttpRequest();
				 request.open("GET","ProductServlet?status=Pvaild&name="+pname,true);
				 request.send();
                 request.onreadystatechange = function (){
					 if(request.readyState == 4 && request.status == 200){
						var i = request.responseText;
					    if (i == "存在") {
					      alert("您输入的商品名称已存在,亲 换个名称哦~");
						}
					 }
				 } 
			}
		</script>
</head>
<body>
<div class="div_add">
		<form action="ProductServlet?status=ProductAdd" method="post" enctype="multipart/form-data" >
		
			     商品名称：<input type="text" name="name" placeholder="商品名称 不能为空" autofocus required  onblur="vaild()" id="pname"><span></span><br>
			     商品描述：<input type="text" name="describe" placeholder="商品描述 不能为空" required ><br>
			     商品数量：<input type="text" name="number" placeholder="商品数量 不能为空 可以为0" required ><br>
			     商品价格：<input type="text" name="price" placeholder="商品价格小数点后两位" required ><br>
			     商品图片：<input type="file" name="img"><br>
			  <input type="submit" value="添加" class="add">   
			  
		</form>
</div>
</body>
</html>
